<template name="classTable">
    <el-table
        :data="bannerList"
        style="width: 100%"
        :row-style="{cursor:'pointer'}"
        row-key="id"
        border
        highlight-current-row
        :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
        <el-table-column
            prop="id"
            align="center"
            label="ID"
            width="100">
        </el-table-column>
        <el-table-column
            label="图片"
            align="center">
            <template scope="scope">
                <img :src="scope.row.banner" width="130" height="70"/>
            </template>
        </el-table-column>
        <el-table-column
                label="分类"
                align="center">
            <template scope="scope">
                <span>{{scope.row.class_type==1?'首页':scope.row.class_type==2?'店铺审核':'积分商城'}}</span>
            </template>
        </el-table-column>
        <el-table-column
                label="跳转方式"
                align="center">
            <template scope="scope">
                <span>{{scope.row.type==1?'商品':scope.row.type==2?'店铺':''}}</span>
            </template>
        </el-table-column>
        <el-table-column
                label="名称"
                align="center">
            <template scope="scope">
                <span>{{scope.row.link_name}}</span>
            </template>
        </el-table-column>
        <el-table-column
            label="权值"
            align="center"
            prop="qz"
        >

        </el-table-column>
        <el-table-column
            label="操作"
            align="center"
            width="300">
            <template scope="scope">
                <el-button
                    size="mini"
                    @click="handleSee(scope.$index, scope.row)">查看</el-button>
                <!--<el-button-->
                        <!--size="mini"-->
                        <!--&gt;权值</el-button>-->
                <el-button
                    size="mini"
                    @click="handleEdit(scope.$index, scope.row)">修改</el-button>
                <el-button
                size="mini"
                    @click="handleDelete(scope.$index, scope.row)">删除</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>

<script>
export default {
    name: "classTable",
    props: ['bannerList'],
    data(){
        return{
        }
    },
    computed:{

    },
    methods: {
        handleSee(index,row){
            console.log(index, row);
            this.$router.push({
                path: '/newBanner',
                query: {
                    type: 4,
                    list: row
                }
            })
        },
        handleEdit(index, row) {
            console.log(index, row);
            this.$router.push({
                path: '/newBanner',
                query: {
                    type: 2,
                    list: row
                }
            })
        },
        handleDelete(index, row) {
            console.log(index, row);
            this.$confirm('此操作将永久删除该banner, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                console.log('del');
                this.operationBanner(row)
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });
        },
        async operationBanner(list){
            // console.log(list);
            let res = await this.$Http.operationBanner({
                type: 3,
                id: list.id
            })
            // console.log(res)
            if(res.code == 1){
                this.$message({
                    type: 'success',
                    message: '此banner删除成功!'
                });
            }
            this.$emit('refreshTableFun')
        }
    }
}
</script>
